/*    */ package com.hp.bon.logreverse;
/*    */ 
/*    */ import com.hp.bon.sgw.bean.XmlMessage;
/*    */ import com.hp.bon.sgw.core.channel.SoapChannel;
/*    */ import com.hp.bon.sgw.util.Comutils;
/*    */ import java.util.ArrayList;
/*    */ import java.util.Date;
/*    */ import org.slf4j.Logger;
/*    */ import org.slf4j.LoggerFactory;
/*    */ 
/*    */ public class SoapDecoder
/*    */   implements IDecoder
/*    */ {
/* 14 */   private static final Logger LOG = LoggerFactory.getLogger(SoapDecoder.class);
/*    */ 
/* 36 */   protected MsgInfo msgInfo = null;
/*    */ 
/*    */   public boolean isMatch(ReverseLogEvent logEvent)
/*    */   {
/* 18 */     String line = logEvent.headStr;
/*    */     boolean isRecv;
			 boolean isRequest;
/* 21 */     if (line.indexOf("http request from") > 0) {
/* 22 */       isRequest = true;
/* 23 */       isRecv = true;
/*    */     }
/*    */     else
/*    */     {
/* 24 */       if (line.indexOf("http response") > 0) {
/* 25 */         isRequest = false;
/* 26 */         isRecv = false;
/*    */       } else {
/* 28 */         return false;
/*    */       }
/*    */     }
/*    */    
/* 30 */     this.msgInfo = new MsgInfo(logEvent);
/* 31 */     this.msgInfo.isRequest = isRequest;
/* 32 */     this.msgInfo.isRecv = isRecv;
/* 33 */     return true;
/*    */   }
/*    */ 
/*    */   public boolean isParse()
/*    */     throws Exception
/*    */   {
/* 45 */     return true;
/*    */   }
/*    */ 
/*    */   public MsgInfo getMsgInfo() {
/* 49 */     return this.msgInfo;
/*    */   }
/*    */ 
/*    */   public MsgInfo parse()
/*    */     throws Exception
/*    */   {
/* 59 */     String line = this.msgInfo.logEvent.headStr;
/* 60 */     String requestTime = line.substring(0, 23);
/* 61 */     long lastProcessTime = Comutils.parseStringTime(requestTime, "yyyy-MM-dd HH:mm:ss.SSS");
/* 62 */     this.msgInfo.setLogDate(new Date(lastProcessTime));
/*    */     XmlMessage msg;
/* 64 */     if (this.msgInfo.isRequest()) {
/* 65 */       StringBuilder sb = new StringBuilder((String)this.msgInfo.logEvent.moreStrList.get(0));
/* 66 */       for (int i = 1; i < this.msgInfo.logEvent.moreStrList.size(); i++) {
/* 67 */         sb.append('\n').append((String)this.msgInfo.logEvent.moreStrList.get(i));
/*    */       }
/* 69 */       msg = SoapChannel.parseWSRequest(sb.toString());
/*    */     } else {
/* 71 */       int index = line.indexOf("http response");
/* 72 */       StringBuilder sb = new StringBuilder(line.substring(index + 13));
/* 73 */       if (this.msgInfo.logEvent.isMoreLine()) {
/* 74 */         for (int i = 0; i < this.msgInfo.logEvent.moreStrList.size(); i++) {
/* 75 */           sb.append('\n').append((String)this.msgInfo.logEvent.moreStrList.get(i));
/*    */         }
/*    */       }
/* 78 */       msg = SoapChannel.parseWSResponse(sb.toString());
/*    */     }
/* 80 */     msg.setMsgTime(lastProcessTime);
/* 81 */     this.msgInfo.msg = msg;
/* 82 */     return this.msgInfo;
/*    */   }
/*    */ }

/* Location:           C:\Users\think\Desktop\sgw_2.1.jar
 * Qualified Name:     com.hp.bon.logreverse.SoapDecoder
 * JD-Core Version:    0.6.1
 */